home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / SciAn / src / util / rots.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  927b  |  46 lines

  1. /*rots.c
  2.   Eric Pepke
  3.  
  4.   Emits a script segment containing a series of rotations about an axis 
  5.   and snaps to standard output
  6.  
  7.   Usage:
  8.     rots axis step nSteps
  9.     axis is the axis about which to rotate (x, y, or z)
  10.   Example:
  11.     rots x 0.5 30 > rot30
  12.  
  13.   puts 30 rotations by 0.5 degree around the x axis with snaps into rot30
  14. */
  15.  
  16. #include <stdio.h>
  17.  
  18. main(argc, argv)
  19. int argc;
  20. char *argv[];
  21. {
  22.     double step;
  23.     int nSteps;
  24.     int k;
  25.     if (argc != 4)
  26.     {
  27.         fprintf(stderr, "usage: %s axis step nSteps\n", argv[0]);
  28.     exit(-1);
  29.     }
  30.     if (1 != sscanf(argv[2], "%lg", &step))
  31.     {
  32.         fprintf(stderr, "usage: %s axis step nSteps\n", argv[0]);
  33.     exit(-1);
  34.     }
  35.     if (1 != sscanf(argv[3], "%d", &nSteps))
  36.     {
  37.         fprintf(stderr, "usage: %s axis step nSteps\n", argv[0]);
  38.     exit(-1);
  39.     }
  40.     for (k = 1; k <= nSteps; ++k)
  41.     {
  42.     printf("rotate %c %lg\n", argv[1][0], step);
  43.     printf("snap\n");
  44.     }
  45. }
  46.